﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Configuration;
using System.Configuration;

namespace Transport.Admin
{
    public partial class QLGiamGia : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                txt_0.Text = WebConfigurationManager.AppSettings["ThoiHanHuy"];
                txt_1.Text = WebConfigurationManager.AppSettings["SauKhiMua"];
                txt_2.Text = WebConfigurationManager.AppSettings["TruocBayNgay"];
                txt_3.Text = WebConfigurationManager.AppSettings["ConLai"];
            }
        }

        protected void DetailsView_GG_ItemInserted(object sender, DetailsViewInsertedEventArgs e)
        {
            GridView_GG.DataBind();
        }

        protected void btn_0_Click(object sender, EventArgs e)
        {
            try
            {
                Configuration config = WebConfigurationManager.OpenWebConfiguration("~");
                config.AppSettings.Settings["ThoiHanHuy"].Value = txt_0.Text;
                config.Save(ConfigurationSaveMode.Modified);
                ConfigurationManager.RefreshSection("appSettings");

                Response.Redirect(HttpContext.Current.Request.Url.AbsoluteUri);
            }
            catch (Exception)
            {
            }
        }

        protected void btn_1_Click(object sender, EventArgs e)
        {
            try
            {
                Configuration config = WebConfigurationManager.OpenWebConfiguration("~");
                config.AppSettings.Settings["SauKhiMua"].Value = txt_1.Text;
                config.Save(ConfigurationSaveMode.Modified);
                ConfigurationManager.RefreshSection("appSettings");

                Response.Redirect(HttpContext.Current.Request.Url.AbsoluteUri);
            }
            catch (Exception)
            {
            }
        }

        protected void btn_2_Click(object sender, EventArgs e)
        {
            try
            {
                Configuration config = WebConfigurationManager.OpenWebConfiguration("~");
                config.AppSettings.Settings["TruocBayNgay"].Value = txt_2.Text;
                config.Save(ConfigurationSaveMode.Modified);
                ConfigurationManager.RefreshSection("appSettings");

                Response.Redirect(HttpContext.Current.Request.Url.AbsoluteUri);
            }
            catch (Exception)
            {
            }
        }

        protected void btn_3_Click(object sender, EventArgs e)
        {
            try
            {
                Configuration config = WebConfigurationManager.OpenWebConfiguration("~");
                config.AppSettings.Settings["ConLai"].Value = txt_3.Text;
                config.Save(ConfigurationSaveMode.Modified);
                ConfigurationManager.RefreshSection("appSettings");

                Response.Redirect(HttpContext.Current.Request.Url.AbsoluteUri);
            }
            catch (Exception)
            {
            }
        }
    }
}